<?php
/**
 * Created by PhpStorm.
 * User: toshiba
 * Date: 2015/4/17
 * Time: 18:33
 */

class service extends Activity{
    //所有服务站
    function getListTask(){
        list($r['data']['list'],$r['data']['total'])=ServiceMode::init()->getList(1);
        $addressMode=AddressMode::init();
        foreach($r['data']['list'] as &$v){
            $v['address_string']=$addressMode->getDetailAsString($v['address_id']);
        }
        usort($r['data']['list'],function($a,$b){
            return ord(substr(iconv('utf-8', 'gbk', $a['service_name']), 0, 1))-
            ord(substr(iconv('utf-8', 'gbk', $b['service_name']), 0, 1));
        });
        $r['resultCode']= $r['data']['total']>0 ? 200:500;
        View::displayAsJson($r);
    }

    //获得当前站点的信息
    function getSiteInfoTask(){
        $site = SiteModule::init();
        $site_id = $site->getCookieSiteId();
        $r['data']=$site->getDetail($site_id);
        $r['resultCode']= !empty($r['data']) ? 200:500;
        View::displayAsJson($r);
    }
} 